package com.ims.DAO;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.ims.hibernate.IngramData;
import com.ims.hibernate.Student;
import com.ims.util.HibernateUtil;



public class IngramDataDAO {
	public static void main(String[] args) {
		IngramDataDAO ingram = new IngramDataDAO();
		
	Long a =	ingram.saveIngramData( "abc",  "abc",  "abc",  "abc",  "abc",  "abc",  "abc", "abc",  "abc",  "abc",  "abc",  "abc",  "abc",  "abc", "abc",  "abc",  "abc",  "abc",  "abc",  "abc",  "abc", "abc",  "abc",  "abc",  "abc",  "abc");
	}
	
	public Long saveIngramData(String actionIndicator, String allianceFlag, String availabilityFlag, String cpuCode, String customerPrice, String ingramCategory, String ingramPartNo
			,String instantRebateFlag, String mediaType, String newItemReceiptFlag, String partDesc1, String partDesc2, String priceChangeFlag, String prodHeight,
			String productLength, String productWidth, String restrictedFlag, String retailPrice, String skuStatus, String specialPriceFlag, String substitutePartNumber,
			String uCPCode, String vendorNo, String vendorPartNo, String weight, String vender_name)
	{
		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction transaction = null;
		Long p = null;
		
		try {
			transaction = session.beginTransaction();
			IngramData ingramData = new IngramData();
			

			ingramData.setActionIndicator(actionIndicator);
			ingramData.setAllianceFlag(allianceFlag);
			ingramData.setAvailabilityFlag(availabilityFlag);
			ingramData.setCpuCode(cpuCode);
			ingramData.setCustomerPrice(customerPrice);
			ingramData.setIngramCategory(ingramCategory);
			ingramData.setIngramPartNo(ingramPartNo);
			ingramData.setInstantRebateFlag(instantRebateFlag);
			ingramData.setMediaType(mediaType);
			ingramData.setNewItemReceiptFlag(newItemReceiptFlag);
			ingramData.setPartDesc1(partDesc1);
			ingramData.setPartDesc2(partDesc2);
			ingramData.setPriceChangeFlag(priceChangeFlag);
			ingramData.setProdHeight(prodHeight);
			ingramData.setProductLength(productLength);
			ingramData.setProductWidth(productWidth);
			ingramData.setRestrictedFlag(restrictedFlag);
			ingramData.setRetailPrice(retailPrice);
			ingramData.setSkuStatus(skuStatus);
			ingramData.setSpecialPriceFlag(specialPriceFlag);
			ingramData.setSubstitutePartNumber(substitutePartNumber);
			
			ingramData.setUCPCode(uCPCode);
			ingramData.setVendorNo(vendorNo);
			ingramData.setVendorPartNo(vendorPartNo);
			ingramData.setWeight(weight);
			ingramData.setVender_name(vender_name);
			

			session.save(ingramData);
			transaction.commit();
		} catch (HibernateException e) {
			transaction.rollback();
			e.printStackTrace();
		} finally {
			session.close();
		}
		return p;
	}
	


}
